import request from '@/utils/request'

// ===== 学术兼职 Academic Positions =====
export const academicPositionApi = {
    listMine(params) {
        return request({ url: '/api/academic-positions/mine', method: 'get', params })
    },
    getById(id) {
        return request({ url: `/api/academic-positions/${id}` , method: 'get' })
    },
    create(data) {
        return request({ url: '/api/academic-positions', method: 'post', data })
    },
    update(id, data) {
        return request({ url: `/api/academic-positions/${id}`, method: 'put', data })
    },
    remove(id) {
        return request({ url: `/api/academic-positions/${id}`, method: 'delete' })
    },
    // 附件
    uploadAttachment(id, file, fileType = '证明材料') {
        const formData = new FormData()
        formData.append('file', file)
        formData.append('fileType', fileType)
        return request({
            url: `/api/academic-positions/${id}/attachments`,
            method: 'post',
            data: formData,
            headers: { 'Content-Type': 'multipart/form-data' }
        })
    },
    listAttachments(id) {
        return request({ url: `/api/academic-positions/${id}/attachments`, method: 'get' })
    },
    deleteAttachment(id, attId) {
        return request({ url: `/api/academic-positions/${id}/attachments/${attId}`, method: 'delete' })
    },
    downloadAttachment(id, attId) {
        return request({ url: `/api/academic-positions/${id}/attachments/${attId}/download`, method: 'get', responseType: 'blob' })
    },
    // 管理员
    listAll(params) {
        return request({ url: '/api/academic-positions/all', method: 'get', params })
    },
    listPending(params) {
        return request({ url: '/api/academic-positions/pending', method: 'get', params })
    },
    review(id, data) {
        return request({ url: `/api/academic-positions/${id}/review`, method: 'post', data })
    },
    stats(params) {
        return request({ url: '/api/academic-positions/stats', method: 'get', params })
    }
}

// ===== 社会服务 Social Services =====
export const socialServiceApi = {
    listMine(params) {
        return request({ url: '/api/social-services/mine', method: 'get', params })
    },
    getById(id) {
        return request({ url: `/api/social-services/${id}` , method: 'get' })
    },
    create(data) {
        return request({ url: '/api/social-services', method: 'post', data })
    },
    update(id, data) {
        return request({ url: `/api/social-services/${id}`, method: 'put', data })
    },
    remove(id) {
        return request({ url: `/api/social-services/${id}`, method: 'delete' })
    },
    // 附件
    uploadAttachment(id, file, fileType = '证明材料') {
        const formData = new FormData()
        formData.append('file', file)
        formData.append('fileType', fileType)
        return request({
            url: `/api/social-services/${id}/attachments`,
            method: 'post',
            data: formData,
            headers: { 'Content-Type': 'multipart/form-data' }
        })
    },
    listAttachments(id) {
        return request({ url: `/api/social-services/${id}/attachments`, method: 'get' })
    },
    deleteAttachment(id, attId) {
        return request({ url: `/api/social-services/${id}/attachments/${attId}`, method: 'delete' })
    },
    downloadAttachment(id, attId) {
        return request({ url: `/api/social-services/${id}/attachments/${attId}/download`, method: 'get', responseType: 'blob' })
    },
    // 管理员
    listAll(params) {
        return request({ url: '/api/social-services/all', method: 'get', params })
    },
    listPending(params) {
        return request({ url: '/api/social-services/pending', method: 'get', params })
    },
    review(id, data) {
        return request({ url: `/api/social-services/${id}/review`, method: 'post', data })
    },
    stats(params) {
        return request({ url: '/api/social-services/stats', method: 'get', params })
    }
} 